﻿using System.Collections.Generic;

namespace RpcHelper.Http
{
    public class HttpHeaderHelper
    {
        private static readonly Dictionary<string, string> _ContentType = new Dictionary<string, string>();
        private static readonly Dictionary<string, string> _FileExtension = new Dictionary<string, string>();

        static HttpHeaderHelper()
        {
            _InitContentType();
            _InitFileExtension();
        }
        private static void _InitFileExtension()
        {
            _FileExtension.Add("text/html", ".html");
            _FileExtension.Add("text/plain", ".txt");
            _FileExtension.Add("image/jpeg", ".jpg");
            _FileExtension.Add("video/mp4", ".mp4");
            _FileExtension.Add("image/gif", ".gif");
            foreach (KeyValuePair<string, string> i in _ContentType)
            {
                if (i.Value == "application/octet-stream")
                {
                    continue;
                }
                else if (!_FileExtension.ContainsKey(i.Value))
                {
                    _FileExtension.Add(i.Value, i.Key);
                }
            }
        }
        private static void _InitContentType()
        {
            _ContentType.Add(".mkv", "video/x-matroska");
            _ContentType.Add(".3gp", "video/3gpp");
            _ContentType.Add(".json", "application/json");
            _ContentType.Add(".aab", "application/x-authoware-bin");
            _ContentType.Add(".aam", "application/x-authoware-map");
            _ContentType.Add(".aas", "application/x-authoware-seg");
            _ContentType.Add(".ai", "application/postscript");
            _ContentType.Add(".aif", "audio/x-aiff");
            _ContentType.Add(".aifc", "audio/x-aiff");
            _ContentType.Add(".aiff", "audio/x-aiff");
            _ContentType.Add(".als", "audio/x-alpha5");
            _ContentType.Add(".amc", "application/x-mpeg");
            _ContentType.Add(".ani", "application/octet-stream");
            _ContentType.Add(".asc", "text/plain");
            _ContentType.Add(".asd", "application/astound");
            _ContentType.Add(".asf", "video/x-ms-asf");
            _ContentType.Add(".asn", "application/astound");
            _ContentType.Add(".asp", "application/x-asap");
            _ContentType.Add(".asx", "video/x-ms-asf");
            _ContentType.Add(".au", "audio/basic");
            _ContentType.Add(".avb", "application/octet-stream");
            _ContentType.Add(".avi", "video/x-msvideo");
            _ContentType.Add(".awb", "audio/amr-wb");
            _ContentType.Add(".bcpio", "application/x-bcpio");
            _ContentType.Add(".bin", "application/octet-stream");
            _ContentType.Add(".bld", "application/bld");
            _ContentType.Add(".bld2", "application/bld2");
            _ContentType.Add(".bmp", "application/x-ms-bmp");
            _ContentType.Add(".bpk", "application/octet-stream");
            _ContentType.Add(".bz2", "application/x-bzip2");
            _ContentType.Add(".cal", "image/x-cals");
            _ContentType.Add(".ccn", "application/x-cnc");
            _ContentType.Add(".cco", "application/x-cocoa");
            _ContentType.Add(".cdf", "application/x-netcdf");
            _ContentType.Add(".cgi", "magnus-internal/cgi");
            _ContentType.Add(".chat", "application/x-chat");
            _ContentType.Add(".class", "application/octet-stream");
            _ContentType.Add(".clp", "application/x-msclip");
            _ContentType.Add(".cmx", "application/x-cmx");
            _ContentType.Add(".co", "application/x-cult3d-object");
            _ContentType.Add(".cod", "image/cis-cod");
            _ContentType.Add(".cpio", "application/x-cpio");
            _ContentType.Add(".cpt", "application/mac-compactpro");
            _ContentType.Add(".crd", "application/x-mscardfile");
            _ContentType.Add(".csh", "application/x-csh");
            _ContentType.Add(".csm", "chemical/x-csml");
            _ContentType.Add(".csml", "chemical/x-csml");
            _ContentType.Add(".css", "text/css");
            _ContentType.Add(".cur", "application/octet-stream");
            _ContentType.Add(".dcm", "x-lml/x-evm");
            _ContentType.Add(".dcr", "application/x-director");
            _ContentType.Add(".dcx", "image/x-dcx");
            _ContentType.Add(".dhtml", "text/html");
            _ContentType.Add(".dir", "application/x-director");
            _ContentType.Add(".dll", "application/octet-stream");
            _ContentType.Add(".dmg", "application/octet-stream");
            _ContentType.Add(".dms", "application/octet-stream");
            _ContentType.Add(".doc", "application/msword");
            _ContentType.Add(".dot", "application/x-dot");
            _ContentType.Add(".dvi", "application/x-dvi");
            _ContentType.Add(".dwf", "drawing/x-dwf");
            _ContentType.Add(".dwg", "application/x-autocad");
            _ContentType.Add(".dxf", "application/x-autocad");
            _ContentType.Add(".dxr", "application/x-director");
            _ContentType.Add(".ebk", "application/x-expandedbook");
            _ContentType.Add(".emb", "chemical/x-embl-dl-nucleotide");
            _ContentType.Add(".embl", "chemical/x-embl-dl-nucleotide");
            _ContentType.Add(".eps", "application/postscript");
            _ContentType.Add(".eri", "image/x-eri");
            _ContentType.Add(".es", "audio/echospeech");
            _ContentType.Add(".esl", "audio/echospeech");
            _ContentType.Add(".etc", "application/x-earthtime");
            _ContentType.Add(".etx", "text/x-setext");
            _ContentType.Add(".evm", "x-lml/x-evm");
            _ContentType.Add(".evy", "application/x-envoy");
            _ContentType.Add(".exe", "application/octet-stream");
            _ContentType.Add(".fh4", "image/x-freehand");
            _ContentType.Add(".fh5", "image/x-freehand");
            _ContentType.Add(".fhc", "image/x-freehand");
            _ContentType.Add(".fif", "image/fif");
            _ContentType.Add(".fm", "application/x-maker");
            _ContentType.Add(".fpx", "image/x-fpx");
            _ContentType.Add(".fvi", "video/isivideo");
            _ContentType.Add(".gau", "chemical/x-gaussian-input");
            _ContentType.Add(".gca", "application/x-gca-compressed");
            _ContentType.Add(".gdb", "x-lml/x-gdb");
            _ContentType.Add(".gif", "image/gif");
            _ContentType.Add(".gps", "application/x-gps");
            _ContentType.Add(".gtar", "application/x-gtar");
            _ContentType.Add(".gz", "application/x-gzip");
            _ContentType.Add(".hdf", "application/x-hdf");
            _ContentType.Add(".hdm", "text/x-hdml");
            _ContentType.Add(".hdml", "text/x-hdml");
            _ContentType.Add(".hlp", "application/winhlp");
            _ContentType.Add(".hqx", "application/mac-binhex40");
            _ContentType.Add(".htm", "text/html");
            _ContentType.Add(".html", "text/html");
            _ContentType.Add(".hts", "text/html");
            _ContentType.Add(".ice", "x-conference/x-cooltalk");
            _ContentType.Add(".ico", "image/x-icon");
            _ContentType.Add(".ief", "image/ief");
            _ContentType.Add(".ifm", "image/gif");
            _ContentType.Add(".ifs", "image/ifs");
            _ContentType.Add(".imy", "audio/melody");
            _ContentType.Add(".ins", "application/x-net-install");
            _ContentType.Add(".ips", "application/x-ipscript");
            _ContentType.Add(".ipx", "application/x-ipix");
            _ContentType.Add(".it", "audio/x-mod");
            _ContentType.Add(".itz", "audio/x-mod");
            _ContentType.Add(".ivr", "i-world/i-vrml");
            _ContentType.Add(".j2k", "image/j2k");
            _ContentType.Add(".jad", "text/vnd.sun.j2me.app-descriptor");
            _ContentType.Add(".jam", "application/x-jam");
            _ContentType.Add(".jar", "application/java-archive");
            _ContentType.Add(".jnlp", "application/x-java-jnlp-file");
            _ContentType.Add(".jpe", "image/jpeg");
            _ContentType.Add(".jpeg", "image/jpeg");
            _ContentType.Add(".jpg", "image/jpeg");
            _ContentType.Add(".jpz", "image/jpeg");
            _ContentType.Add(".js", "application/x-javascript");
            _ContentType.Add(".jwc", "application/jwc");
            _ContentType.Add(".kjx", "application/x-kjx");
            _ContentType.Add(".lak", "x-lml/x-lak");
            _ContentType.Add(".latex", "application/x-latex");
            _ContentType.Add(".lcc", "application/fastman");
            _ContentType.Add(".lcl", "application/x-digitalloca");
            _ContentType.Add(".lcr", "application/x-digitalloca");
            _ContentType.Add(".lgh", "application/lgh");
            _ContentType.Add(".lha", "application/octet-stream");
            _ContentType.Add(".lml", "x-lml/x-lml");
            _ContentType.Add(".lmlpack", "x-lml/x-lmlpack");
            _ContentType.Add(".lsf", "video/x-ms-asf");
            _ContentType.Add(".lsx", "video/x-ms-asf");
            _ContentType.Add(".lzh", "application/x-lzh");
            _ContentType.Add(".m13", "application/x-msmediaview");
            _ContentType.Add(".m14", "application/x-msmediaview");
            _ContentType.Add(".m15", "audio/x-mod");
            _ContentType.Add(".m3u", "audio/x-mpegurl");
            _ContentType.Add(".m3url", "audio/x-mpegurl");
            _ContentType.Add(".ma1", "audio/ma1");
            _ContentType.Add(".ma2", "audio/ma2");
            _ContentType.Add(".ma3", "audio/ma3");
            _ContentType.Add(".ma5", "audio/ma5");
            _ContentType.Add(".man", "application/x-troff-man");
            _ContentType.Add(".map", "magnus-internal/imagemap");
            _ContentType.Add(".mbd", "application/mbedlet");
            _ContentType.Add(".mct", "application/x-mascot");
            _ContentType.Add(".mdb", "application/x-msaccess");
            _ContentType.Add(".mdz", "audio/x-mod");
            _ContentType.Add(".me", "application/x-troff-me");
            _ContentType.Add(".mel", "text/x-vmel");
            _ContentType.Add(".mi", "application/x-mif");
            _ContentType.Add(".mid", "audio/midi");
            _ContentType.Add(".midi", "audio/midi");
            _ContentType.Add(".mif", "application/x-mif");
            _ContentType.Add(".mil", "image/x-cals");
            _ContentType.Add(".mio", "audio/x-mio");
            _ContentType.Add(".mmf", "application/x-skt-lbs");
            _ContentType.Add(".mng", "video/x-mng");
            _ContentType.Add(".mny", "application/x-msmoney");
            _ContentType.Add(".moc", "application/x-mocha");
            _ContentType.Add(".mocha", "application/x-mocha");
            _ContentType.Add(".mod", "audio/x-mod");
            _ContentType.Add(".mof", "application/x-yumekara");
            _ContentType.Add(".mol", "chemical/x-mdl-molfile");
            _ContentType.Add(".mop", "chemical/x-mopac-input");
            _ContentType.Add(".mov", "video/quicktime");
            _ContentType.Add(".movie", "video/x-sgi-movie");
            _ContentType.Add(".mp2", "audio/x-mpeg");
            _ContentType.Add(".mp3", "audio/mpeg");
            _ContentType.Add(".mp4", "video/mp4");
            _ContentType.Add(".mpc", "application/vnd.mpohun.certificate");
            _ContentType.Add(".mpe", "video/mpeg");
            _ContentType.Add(".mpeg", "video/mpeg");
            _ContentType.Add(".mpg", "video/mpeg");
            _ContentType.Add(".mpg4", "video/mp4");
            _ContentType.Add(".mpga", "audio/mpeg");
            _ContentType.Add(".mpn", "application/vnd.mophun.application");
            _ContentType.Add(".mpp", "application/vnd.ms-project");
            _ContentType.Add(".mps", "application/x-mapserver");
            _ContentType.Add(".mrl", "text/x-mrml");
            _ContentType.Add(".mrm", "application/x-mrm");
            _ContentType.Add(".ms", "application/x-troff-ms");
            _ContentType.Add(".mts", "application/metastream");
            _ContentType.Add(".mtx", "application/metastream");
            _ContentType.Add(".mtz", "application/metastream");
            _ContentType.Add(".mzv", "application/metastream");
            _ContentType.Add(".nar", "application/zip");
            _ContentType.Add(".nbmp", "image/nbmp");
            _ContentType.Add(".nc", "application/x-netcdf");
            _ContentType.Add(".ndb", "x-lml/x-ndb");
            _ContentType.Add(".ndwn", "application/ndwn");
            _ContentType.Add(".nif", "application/x-nif");
            _ContentType.Add(".nmz", "application/x-scream");
            _ContentType.Add(".nokia-op-logo", "image/vnd.nok-oplogo-color");
            _ContentType.Add(".npx", "application/x-netfpx");
            _ContentType.Add(".nsnd", "audio/nsnd");
            _ContentType.Add(".nva", "application/x-neva1");
            _ContentType.Add(".oda", "application/oda");
            _ContentType.Add(".oom", "application/x-atlasmate-plugin");
            _ContentType.Add(".pac", "audio/x-pac");
            _ContentType.Add(".pae", "audio/x-epac");
            _ContentType.Add(".pan", "application/x-pan");
            _ContentType.Add(".pbm", "image/x-portable-bitmap");
            _ContentType.Add(".pcx", "image/x-pcx");
            _ContentType.Add(".pda", "image/x-pda");
            _ContentType.Add(".pdb", "chemical/x-pdb");
            _ContentType.Add(".pdf", "application/pdf");
            _ContentType.Add(".pfr", "application/font-tdpfr");
            _ContentType.Add(".pgm", "image/x-portable-graymap");
            _ContentType.Add(".pict", "image/x-pict");
            _ContentType.Add(".pm", "application/x-perl");
            _ContentType.Add(".pmd", "application/x-pmd");
            _ContentType.Add(".png", "image/png");
            _ContentType.Add(".pnm", "image/x-portable-anymap");
            _ContentType.Add(".pnz", "image/png");
            _ContentType.Add(".pot", "application/vnd.ms-powerpoint");
            _ContentType.Add(".ppm", "image/x-portable-pixmap");
            _ContentType.Add(".pps", "application/vnd.ms-powerpoint");
            _ContentType.Add(".ppt", "application/vnd.ms-powerpoint");
            _ContentType.Add(".pqf", "application/x-cprplayer");
            _ContentType.Add(".pqi", "application/cprplayer");
            _ContentType.Add(".prc", "application/x-prc");
            _ContentType.Add(".proxy", "application/x-ns-proxy-autoconfig");
            _ContentType.Add(".ps", "application/postscript");
            _ContentType.Add(".ptlk", "application/listenup");
            _ContentType.Add(".pub", "application/x-mspublisher");
            _ContentType.Add(".pvx", "video/x-pv-pvx");
            _ContentType.Add(".qcp", "audio/vnd.qcelp");
            _ContentType.Add(".qt", "video/quicktime");
            _ContentType.Add(".qti", "image/x-quicktime");
            _ContentType.Add(".qtif", "image/x-quicktime");
            _ContentType.Add(".r3t", "text/vnd.rn-realtext3d");
            _ContentType.Add(".ra", "audio/x-pn-realaudio");
            _ContentType.Add(".ram", "audio/x-pn-realaudio");
            _ContentType.Add(".rar", "application/x-rar-compressed");
            _ContentType.Add(".ras", "image/x-cmu-raster");
            _ContentType.Add(".rdf", "application/rdf+xml");
            _ContentType.Add(".rf", "image/vnd.rn-realflash");
            _ContentType.Add(".rgb", "image/x-rgb");
            _ContentType.Add(".rlf", "application/x-richlink");
            _ContentType.Add(".rm", "audio/x-pn-realaudio");
            _ContentType.Add(".rmf", "audio/x-rmf");
            _ContentType.Add(".rmm", "audio/x-pn-realaudio");
            _ContentType.Add(".rmvb", "audio/x-pn-realaudio");
            _ContentType.Add(".rnx", "application/vnd.rn-realplayer");
            _ContentType.Add(".roff", "application/x-troff");
            _ContentType.Add(".rp", "image/vnd.rn-realpix");
            _ContentType.Add(".rpm", "audio/x-pn-realaudio-plugin");
            _ContentType.Add(".rt", "text/vnd.rn-realtext");
            _ContentType.Add(".rte", "x-lml/x-gps");
            _ContentType.Add(".rtf", "application/rtf");
            _ContentType.Add(".rtg", "application/metastream");
            _ContentType.Add(".rtx", "text/richtext");
            _ContentType.Add(".rv", "video/vnd.rn-realvideo");
            _ContentType.Add(".rwc", "application/x-rogerwilco");
            _ContentType.Add(".s3m", "audio/x-mod");
            _ContentType.Add(".s3z", "audio/x-mod");
            _ContentType.Add(".sca", "application/x-supercard");
            _ContentType.Add(".scd", "application/x-msschedule");
            _ContentType.Add(".sdf", "application/e-score");
            _ContentType.Add(".sea", "application/x-stuffit");
            _ContentType.Add(".sgm", "text/x-sgml");
            _ContentType.Add(".sgml", "text/x-sgml");
            _ContentType.Add(".sh", "application/x-sh");
            _ContentType.Add(".shar", "application/x-shar");
            _ContentType.Add(".shtml", "magnus-internal/parsed-html");
            _ContentType.Add(".shw", "application/presentations");
            _ContentType.Add(".si6", "image/si6");
            _ContentType.Add(".si7", "image/vnd.stiwap.sis");
            _ContentType.Add(".si9", "image/vnd.lgtwap.sis");
            _ContentType.Add(".sis", "application/vnd.symbian.install");
            _ContentType.Add(".sit", "application/x-stuffit");
            _ContentType.Add(".skd", "application/x-koan");
            _ContentType.Add(".skm", "application/x-koan");
            _ContentType.Add(".skp", "application/x-koan");
            _ContentType.Add(".skt", "application/x-koan");
            _ContentType.Add(".slc", "application/x-salsa");
            _ContentType.Add(".smd", "audio/x-smd");
            _ContentType.Add(".smi", "application/smil");
            _ContentType.Add(".smil", "application/smil");
            _ContentType.Add(".smp", "application/studiom");
            _ContentType.Add(".smz", "audio/x-smd");
            _ContentType.Add(".snd", "audio/basic");
            _ContentType.Add(".spc", "text/x-speech");
            _ContentType.Add(".spl", "application/futuresplash");
            _ContentType.Add(".spr", "application/x-sprite");
            _ContentType.Add(".sprite", "application/x-sprite");
            _ContentType.Add(".spt", "application/x-spt");
            _ContentType.Add(".src", "application/x-wais-source");
            _ContentType.Add(".stk", "application/hyperstudio");
            _ContentType.Add(".stm", "audio/x-mod");
            _ContentType.Add(".sv4cpio", "application/x-sv4cpio");
            _ContentType.Add(".sv4crc", "application/x-sv4crc");
            _ContentType.Add(".svf", "image/vnd");
            _ContentType.Add(".svg", "image/svg-xml");
            _ContentType.Add(".woff", "application/x-font-woff");
            _ContentType.Add(".woff2", "application/x-font-woff");
            _ContentType.Add(".svh", "image/svh");
            _ContentType.Add(".svr", "x-world/x-svr");
            _ContentType.Add(".swf", "application/x-shockwave-flash");
            _ContentType.Add(".swfl", "application/x-shockwave-flash");
            _ContentType.Add(".t", "application/x-troff");
            _ContentType.Add(".tad", "application/octet-stream");
            _ContentType.Add(".talk", "text/x-speech");
            _ContentType.Add(".tar", "application/x-tar");
            _ContentType.Add(".taz", "application/x-tar");
            _ContentType.Add(".tbp", "application/x-timbuktu");
            _ContentType.Add(".tbt", "application/x-timbuktu");
            _ContentType.Add(".tcl", "application/x-tcl");
            _ContentType.Add(".tex", "application/x-tex");
            _ContentType.Add(".texi", "application/x-texinfo");
            _ContentType.Add(".texinfo", "application/x-texinfo");
            _ContentType.Add(".tgz", "application/x-tar");
            _ContentType.Add(".thm", "application/vnd.eri.thm");
            _ContentType.Add(".tif", "image/tiff");
            _ContentType.Add(".tiff", "image/tiff");
            _ContentType.Add(".tki", "application/x-tkined");
            _ContentType.Add(".tkined", "application/x-tkined");
            _ContentType.Add(".toc", "application/toc");
            _ContentType.Add(".toy", "image/toy");
            _ContentType.Add(".tr", "application/x-troff");
            _ContentType.Add(".trk", "x-lml/x-gps");
            _ContentType.Add(".trm", "application/x-msterminal");
            _ContentType.Add(".tsi", "audio/tsplayer");
            _ContentType.Add(".tsp", "application/dsptype");
            _ContentType.Add(".tsv", "text/tab-separated-values");
            _ContentType.Add(".ttf", "application/octet-stream");
            _ContentType.Add(".ttz", "application/t-time");
            _ContentType.Add(".txt", "text/plain");
            _ContentType.Add(".ult", "audio/x-mod");
            _ContentType.Add(".ustar", "application/x-ustar");
            _ContentType.Add(".uu", "application/x-uuencode");
            _ContentType.Add(".uue", "application/x-uuencode");
            _ContentType.Add(".vcd", "application/x-cdlink");
            _ContentType.Add(".vcf", "text/x-vcard");
            _ContentType.Add(".vdo", "video/vdo");
            _ContentType.Add(".vib", "audio/vib");
            _ContentType.Add(".viv", "video/vivo");
            _ContentType.Add(".vivo", "video/vivo");
            _ContentType.Add(".vmd", "application/vocaltec-media-desc");
            _ContentType.Add(".vmf", "application/vocaltec-media-file");
            _ContentType.Add(".vmi", "application/x-dreamcast-vms-info");
            _ContentType.Add(".vms", "application/x-dreamcast-vms");
            _ContentType.Add(".vox", "audio/voxware");
            _ContentType.Add(".vqe", "audio/x-twinvq-plugin");
            _ContentType.Add(".vqf", "audio/x-twinvq");
            _ContentType.Add(".vql", "audio/x-twinvq");
            _ContentType.Add(".vre", "x-world/x-vream");
            _ContentType.Add(".vrml", "x-world/x-vrml");
            _ContentType.Add(".vrt", "x-world/x-vrt");
            _ContentType.Add(".vrw", "x-world/x-vream");
            _ContentType.Add(".vts", "workbook/formulaone");
            _ContentType.Add(".wav", "audio/x-wav");
            _ContentType.Add(".wax", "audio/x-ms-wax");
            _ContentType.Add(".wbmp", "image/vnd.wap.wbmp");
            _ContentType.Add(".web", "application/vnd.xara");
            _ContentType.Add(".wi", "image/wavelet");
            _ContentType.Add(".wis", "application/x-installshield");
            _ContentType.Add(".wm", "video/x-ms-wm");
            _ContentType.Add(".wma", "audio/x-ms-wma");
            _ContentType.Add(".wmd", "application/x-ms-wmd");
            _ContentType.Add(".wmf", "application/x-msmetafile");
            _ContentType.Add(".wml", "text/vnd.wap.wml");
            _ContentType.Add(".wmlc", "application/vnd.wap.wmlc");
            _ContentType.Add(".wmls", "text/vnd.wap.wmlscript");
            _ContentType.Add(".wmlsc", "application/vnd.wap.wmlscriptc");
            _ContentType.Add(".wmlscript", "text/vnd.wap.wmlscript");
            _ContentType.Add(".wmv", "audio/x-ms-wmv");
            _ContentType.Add(".wmx", "video/x-ms-wmx");
            _ContentType.Add(".wmz", "application/x-ms-wmz");
            _ContentType.Add(".wpng", "image/x-up-wpng");
            _ContentType.Add(".wpt", "x-lml/x-gps");
            _ContentType.Add(".wri", "application/x-mswrite");
            _ContentType.Add(".wrl", "x-world/x-vrml");
            _ContentType.Add(".wrz", "x-world/x-vrml");
            _ContentType.Add(".ws", "text/vnd.wap.wmlscript");
            _ContentType.Add(".wsc", "application/vnd.wap.wmlscriptc");
            _ContentType.Add(".wv", "video/wavelet");
            _ContentType.Add(".wvx", "video/x-ms-wvx");
            _ContentType.Add(".wxl", "application/x-wxl");
            _ContentType.Add(".x-gzip", "application/x-gzip");
            _ContentType.Add(".xar", "application/vnd.xara");
            _ContentType.Add(".xbm", "image/x-xbitmap");
            _ContentType.Add(".xdm", "application/x-xdma");
            _ContentType.Add(".xdma", "application/x-xdma");
            _ContentType.Add(".xdw", "application/vnd.fujixerox.docuworks");
            _ContentType.Add(".xht", "application/xhtml+xml");
            _ContentType.Add(".xhtm", "application/xhtml+xml");
            _ContentType.Add(".xhtml", "application/xhtml+xml");
            _ContentType.Add(".xla", "application/vnd.ms-excel");
            _ContentType.Add(".xlc", "application/vnd.ms-excel");
            _ContentType.Add(".xll", "application/x-excel");
            _ContentType.Add(".xlm", "application/vnd.ms-excel");
            _ContentType.Add(".xls", "application/vnd.ms-excel");
            _ContentType.Add(".xlt", "application/vnd.ms-excel");
            _ContentType.Add(".xlw", "application/vnd.ms-excel");
            _ContentType.Add(".xm", "audio/x-mod");
            _ContentType.Add(".xml", "text/xml");
            _ContentType.Add(".xmz", "audio/x-mod");
            _ContentType.Add(".xpi", "application/x-xpinstall");
            _ContentType.Add(".xpm", "image/x-xpixmap");
            _ContentType.Add(".xsit", "text/xml");
            _ContentType.Add(".xsl", "text/xml");
            _ContentType.Add(".xul", "text/xul");
            _ContentType.Add(".xwd", "image/x-xwindowdump");
            _ContentType.Add(".xyz", "chemical/x-pdb");
            _ContentType.Add(".yz1", "application/x-yz1");
            _ContentType.Add(".z", "application/x-compress");
            _ContentType.Add(".zac", "application/x-zaurus-zac");
            _ContentType.Add(".zip", "application/zip");
            _ContentType.Add(".amr", "audio/amr");
            _ContentType.Add(".umd", "application/umd");
            _ContentType.Add(".mtf", "application/mtf");
            _ContentType.Add(".cab", "application/vnd.smartpohone");
            _ContentType.Add(".hme", "application/vnd.smartphone.thm");
            _ContentType.Add(".ogg", "application/ogg");
            _ContentType.Add(".rng", "application/vnd.nokia.ringing-tone");
            _ContentType.Add(".sdt", "application/vnd.sie.thm");
            _ContentType.Add(".tsk", "application/vnd.ppc.thm");
            _ContentType.Add(".utz", "application/vnd.uiq.thm");
            _ContentType.Add(".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            _ContentType.Add(".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
            _ContentType.Add(".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
        }
        public static void RegContentType(Dictionary<string,string> dic)
        {
            dic.ForEach((a, b) =>
            {
                _ContentType.AddOrSet(a, b);
                _FileExtension.AddOrSet(b, a);
            });

        }
        public static string GetContentType(string extension)
        {
            return _ContentType.TryGetValue(extension, out string type) ? type : "application/octet-stream";
        }
        public static bool FindContentType(string extension, ref string contentType)
        {
            return _ContentType.TryGetValue(extension, out contentType);
        }
        public static string GetExtension(string contentType)
        {
            if (_FileExtension.TryGetValue(contentType, out string ext))
            {
                return ext;
            }
            return null;
        }
    }
}
